<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<!DOCTYPE html>
<html lang="zh-CN" >
<head>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>账户信息</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
        <form id="changeAcc_form">
        <div class="fieldset1 tabel_col tabel_col_1 clearFix">
           <div class="caption">
            	账户信息详情
            </div>
            <div class="fieldBox col_50">
                <div class="label">类型</div>
                <div class="field">
                    <span name="accTypNm" id="accTypNm">&nbsp;</span>
                    
                    <input name="accTypCd" id="accTypCd" type="hidden" value="${sysBkAccInfoVO.accTypCd}">
                </div>
            </div>
            <div class="fieldBox col_50">
                <div class="label">开户行</div>
                <div class="field">
                    <span name="bkNm" id="bkNmC">&nbsp;</span>
                </div>
            </div>
            <div class="fieldBox col_50">
                <div class="label">账号名称</div>
                <div class="field">
                    <input name="accNm" id="accNm" type="text" class="ui-textbox" value="${sysBkAccInfoVO.accNm}" validate="{required:true}">
                    <span class="requiredSymbol">*</span>
                </div>
            </div>
            <div class="fieldBox col_50">
                <div class="label">账号</div>
                <div class="field">
                    <input name="accNo" id="accNo" type="text" class="ui-textbox" value="${sysBkAccInfoVO.accNo }" validate="{required:true}">
                    <span class="requiredSymbol">*</span>
                </div>
            </div>
            <div class="fieldBox col_50" >
                <div class="label">支持平台</div>
                <div class="field">
                  	<c:forEach items="${sysOrgList }" var="item" begin="0" step="1" varStatus="status">
                        	<input type="checkbox" orgcd="${item.orgCd }" orgid="${item.id }" value="${item.id }" name="orgIds" />${item.orgNm }<br/>	
                  	</c:forEach>
                </div>
            </div>
            <div class="fieldBox col_100">
                <div class="label">账户备注</div>
                <div class="field">
                    <input name="accRem" id="accRem" type="text" class="ui-textbox" value="${sysBkAccInfoVO.accRem }">
                </div>
            </div>
        </div>
        <div class="btnsBox">
            <span id="saveChangeAcc_Btn" onclick="save()" class="sq-button sq-button-hasicon"><i class="sqBtnIco_10"></i>保存</span>
        </div>
        <div style="display:none"> 
           	<input type="text" value="${sysBkAccInfoVO.id }" name="dataId" id="dataId"/>
           	<input type="text" value="${sysBkAccInfoVO.orgIdsList }" name="orgIdsList" id="orgIdsList"/>
        </div>
    </form>
<script>
		var addBankData_s={
		
		}
		$(function() {
		   $("#changeAcc_form").ligerForm({
                validate: true
           });
		   var orgIdsList=$("#orgIdsList").val();
	   	 	var _orgIds = orgIdsList;
	   	    var _org = $('input:checkbox[name="orgIds"]');
	     	for(var i = 0; i<_org.length; i++){
		     	_org_val=$(_org[i]).val();
		     	if(_orgIds.indexOf((+_org_val))>=0){
	     			$(_org[i]).ligerGetCheckBoxManager().setValue(true);
	     		}
	     	}
		   initData();//初始化数据
		   //SET_popupIframeHeight();
	});
	//初始化数据
	function initData(){
		var id=$('#dataId').val();
		$.ajax({
			type: 'get',
			dataType:'json',
			data:{id:id},
			url: '<%=path%>/system/sysBkAccInfo/getById.do',
			success:function(msg){
				if(msg.success == 1){
					setData(msg.data);//设置数据
				 }else{
					 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
				 }
			}
		});
	}//设置页面数据
	function setData(data){
		var form = new liger.get("changeAcc_form");
		addBankData_s.id=data.id;
		addBankData_s.bkId=data.bkId;
		addBankData_s.accTypCd=data.accTypCd;
		/* form.setData({
			accTypCd:data.accTypCd,
			accNm:data.accNm,
			accNo:data.accNo,
			accRem:data.accRem,
			//orgIdsList:data.orgIdsList
		}); */
		$("#accTypNm").html(data.accTypNm);
		$("#bkNmC").html(data.bkNm);
	}
	//ajax 保存
	function save(){
	    var form = liger.get("changeAcc_form");
        if (!form.valid()) {
        	$.ligerDialog.SQalert({content:LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO, SQ_type: "warning"});
            return false; 
        }
        var data = form.getData();
        $.extend(true, data, addBankData_s); //合并要修改的账号信息(主键id,开户行id)
        
        //复选框数据
        var _org = $('input:checkbox[name="orgIds"]:checked');
        //var _orgIds = [];
        var newJSON = {orgJSON:[]};
        for(var i = 0; i < _org.length; i++){
        	if(_org[i].checked){
        		//_orgIds.push(_org[i].value);
        		var org = '{orgId:"'+$(_org[i]).attr("orgid")+'",orgCd:"'+$(_org[i]).attr("orgcd")+'"}';
        		newJSON.orgJSON.push(org);
        	}
        }
        data["orgJSON"] = "["+newJSON.orgJSON+"]";

        $.ligerDialog.hide();
		var wait_dialog;
		$.ajax({
			type: 'post',
			dataType:'json',
			data:data,
			url: '<%=path%>/system/sysBkAccInfo/modify.do',
			beforeSend:function(){
				wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
			},
			success:function(msg){
				wait_dialog.close();
				if(msg.success == 1){
					 $.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
					 //grid.reload();
				 }else{
					 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
				 }
				
				 
			}
		});
	}
	</script>
</body>
</html>
